import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import legacy from '@vitejs/plugin-legacy'
import vue2 from '@vitejs/plugin-vue2'
import vueJsx from '@vitejs/plugin-vue2-jsx' 
import postcssImport from "postcss-import"
import autoprefixer from 'autoprefixer'
// import tailwindcss from 'tailwindcss'

// https://vitejs.dev/config/
export default defineConfig({
  publicDir: './',
  plugins: [
    vue2(),
    legacy({
      targets: ['ie >= 10'],
      additionalLegacyPolyfills: ['regenerator-runtime/runtime']
    }),
    vueJsx({
      // options are passed on to @vue/babel-preset-jsx
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    open: true,
  },
  rules: {
    "vue/multi-word-component-names": "off",
  },
  //样式表插件
  css: {
    postcss: {
      plugins: [
        postcssImport,
        // postcssCssVariables,
        autoprefixer,
        // tailwindcss
      ]
    },
    preprocessorOptions: {
      scss: {
        // 定义全局的scss变量
        // 给导入的路径最后加上 ; 
        additionalData: `@import '@/style/common.scss';`
      }
    }
  }
})
